<?php
declare (strict_types = 1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class T_PM_PROJECT_DETAIL extends Model
{
    public $table='T_PM_PROJECT_DETAIL';
    public $connection='mysql';
    public function index($PROJECT_NO){
        $ITEM_CODE=$this->where('PROJECT_NO','=',$PROJECT_NO)->value('ITEM_CODE');
        return $ITEM_CODE;
    }
    public function produce($PROJECT_NOS,$order='asc'){
       $list=$this->alias('a')
           ->leftjoin('T_WMS_PO_DETAIL b','a.ITEM_CODE=b.ITEM_CODE')
           ->leftjoin('T_WMS_PO_INFO c','b.PO_DOC=c.PO_DOC')
           ->whereIn('a.PROJECT_NO',$PROJECT_NOS)
           ->field('DATEDIFF(day,a.CREATE_TIME,c.OPEN_TIME) as time')
           ->order('time',"$order")->find()->toArray();
       return $list;
    }
}
